home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 June: Reference Library / Dev.CD Jun 00 RL Disk 1.toast / pc / technical documentation / develop / develop issue 24 / develop issue 24 code / scriptable database 1.0a15.sea / Scriptable Database 1.0a15 / Foundation / MarkToken.h / MarkToken.h
Encoding:
C/C++ Source or Header  |  1996-02-20  |  5.0 KB  |  148 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        MarkToken.h
  3.  
  4.     Contains:    A token that contains a set of other tokens
  5.  
  6.     Written by:    Andy Nicholas, Greg Anderson, Tom Conrad, Chris Bingham, Georgiann Puckett, John Thompson-Rohrlich
  7.  
  8.     Copyright:    © 1994-1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.          <5>      6/6/95    ga        
  11.  
  12. */
  13.  
  14. #ifndef MarkToken_h
  15. #define MarkToken_h
  16.  
  17. //
  18. // ProxyToken.h is needed because
  19. // TProxyToken is the base class of TMarkToken
  20. //
  21. #include "ProxyToken.h"
  22.  
  23. //
  24. // TAbstractIterator is the base class of TMarkIterator
  25. //
  26. #include "AbstractIterator.h"
  27.  
  28. class AListOf<TAbstractScriptableObject*>;
  29.  
  30. #define cMarkToken 'mark'
  31.  
  32. //
  33. // Needed for a callback in MoreAEM
  34. //
  35. TAbstractScriptableObject* MarkTokenMergeProc(TAbstractScriptableObject* baseToken, TAbstractScriptableObject* mergeToken);
  36.  
  37. //========================================================================================
  38. //
  39. //    CLASS TMarkToken
  40. //
  41. //========================================================================================
  42.  
  43. class TMarkToken : public TProxyToken
  44.     {
  45. public:
  46.     DeclareSmallClassData(TMarkToken, TProxyToken);
  47.  
  48.                                         TMarkToken(TypeOfMarkToken markType) : fMarkList(nil), fIsUnionMark(markType) {};
  49.                                         TMarkToken(AListOf<TAbstractScriptableObject*>* list, TypeOfMarkToken markType) : fMarkList(list), fIsUnionMark(markType) {};
  50.     virtual                                ~TMarkToken();
  51.  
  52.     virtual void                        CloneOwnedObjects();
  53.     
  54.     void                                IMarkToken();
  55.     void                                SetUnionMark(TypeOfMarkToken isUnionMark) { fIsUnionMark = isUnionMark; }
  56.     Boolean                                IsUnionMark() { return (fIsUnionMark == kSingleItemOrUnion) || (fIsUnionMark == kPropertyUnion); }
  57.     
  58.     virtual Boolean                        DerivedFromOSLClass(const TAETransaction& t, DescType objectClass);
  59.     virtual DescType                    DefaultType(const TAETransaction& t, DescType propertyName);
  60.     virtual DescType                    BestType(const TAETransaction& t, DescType propertyName);
  61.  
  62.     virtual TAbstractObjectIterator*    DirectObjectIterator(const TAETransaction&);
  63.     virtual TAbstractObjectIterator*    ElementIterator(const TAETransaction&);
  64.  
  65.     virtual TAbstractScriptableObject*    AdoptToken(TAbstractScriptableObject* token, TypeOfMarkToken);
  66.     virtual void                        AddThisToMarkToken(TAbstractScriptableObject*& markToken, TypeOfMarkToken);
  67.  
  68.     virtual void                        AdjustMarks(long newStart, long newStop);
  69.     
  70. protected:
  71.     
  72.     //
  73.     // fMarkList is a list of all of the tokens designated by the mark token
  74.     //
  75.     AListOf<TAbstractScriptableObject*>*                fMarkList;
  76.     
  77.     //
  78.     // fIsUnionMark is true if this mark token was created in order to
  79.     // silently union together multiple hits to a request that is usually
  80.     // matched by a single token (e.g. AccessByName, as in 'folder "Bad Idea"
  81.     // of desktop', when there are two folders named "Bad Idea" on the desktop).
  82.     //
  83.     // Tokens unioned together in this manner will behave as a single
  84.     // container; for example, 'count folder "Bad Idea" of desktop each item' will
  85.     // return the sum of the number of items inside each folder named
  86.     // "Bad idea" on the desktop.  This is different than the behavior of
  87.     // non-union mark tokens; for example, 'count every folder of desktop
  88.     // whose name is "Bad Idea" each item' will return the number of
  89.     // folders named "Bad Idea" on the desktop, because 'whose' clauses do
  90.     // not generate union mark tokens.
  91.     //
  92.     // The only variation on behavior is in CaclulateCount and AccessByIndex.
  93.     // I was tempted to make a class TUnionMarkToken : public TMarkToken, but
  94.     // I was unsure if I might need to dynamicly transmogrify a non-union mark
  95.     // into a union mark.
  96.     //
  97.     TypeOfMarkToken                     fIsUnionMark;
  98.     };
  99.  
  100.  
  101. class TScriptableObjectListIterator;
  102.  
  103.  
  104. //========================================================================================
  105. // Class TMarkTokenIterator
  106. //========================================================================================
  107. class TMarkTokenIterator : public TAbstractObjectIterator
  108. {
  109. private:
  110.     TScriptableObjectListIterator*    fListIter;
  111.     TAbstractObjectIterator*        fCurrentIter;
  112.     Boolean                            fDirection;
  113.     
  114.     AListOf<TAbstractScriptableObject*>*            fMarkList;
  115.     Boolean                            fIterateElements;
  116.     Boolean                            fRequireExists;
  117.     Boolean                            fDeleteListOnDestruction;
  118.     
  119. public:
  120.     TMarkTokenIterator(AListOf<TAbstractScriptableObject*>* markList, Boolean iterateElements, Boolean requireExists, Boolean deleteListOnDestruction = false) :
  121.         fListIter(nil),
  122.         fCurrentIter(nil),
  123.         fDirection(kForwardIteration),
  124.         fMarkList(markList),
  125.         fIterateElements(iterateElements),
  126.         fRequireExists(requireExists),
  127.         fDeleteListOnDestruction(deleteListOnDestruction) { this->Reset(TAETransaction(), kForwardIteration); }
  128.  
  129.     virtual ~TMarkTokenIterator();
  130.     
  131.     //
  132.     // Interface to code to:
  133.     //
  134.     virtual void                        Reset(const TAETransaction& t, Boolean iterationDirection = kForwardIteration);
  135.     virtual Boolean                        More(const TAETransaction&) const;
  136.     virtual void                        Next(const TAETransaction&);
  137.     virtual TAbstractScriptableObject*    Current(const TAETransaction&);
  138.  
  139.     virtual void                        SearchDeep(const TAETransaction& t, TAbstractCollector* collector, DescType desiredClass, TAbstractSearchSpec* searchSpec);
  140.     
  141. private:
  142.     void                                SetupCurrentIterator(const TAETransaction& t);
  143. };
  144.  
  145.  
  146. #endif
  147.  
  148.